const Mock = require('mockjs')
const List = []
const count = 10
const count1 = 18
const searchdata = []
for (let i = 0; i < count; i++) {
  List.push(Mock.mock({
    id: '@increment',
    timestamp: +Mock.Random.date('T'),
    author: '@cname',
    auditor: '@cname',
    title: '@ctitle(10, 20)',
    forecast: '@float(0, 100, 2, 2)',
    importance: '@integer(1, 3)',
    'type|1': ['CN', 'US', 'JP', 'EU'],
    'status|1': ['published', 'draft', 'deleted'],
    pageviews: '@integer(300, 5000)'
  }))
}

for (let i = 0; i < count1; i++) {
  searchdata.push(Mock.mock({
    date: '@date("yyyy-MM-dd")',
    type: '@cname',
    address: '@url',
    money: '@float(0, 100, 2, 2)'
  }))
}

module.exports = {
  'GET /test'(req, res) {
    const response = {}
    response.data = List
    res.json(response)
  },
  'GET /user/info'(req, res) {
    const response = {
      code: 20000,
      data: {
        avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
        name: 'admin',
        roles: ['admin']
      }
    }
    res.json(response)
  },
  'POST /user/login'(req, res) {
    const response = {
      code: 20000,
      data: {
        token: 'admin'
      }
    }
    res.json(response)
  },
  'POST /user/logout'(req, res) {
    const response = {
      code: 20000,
      data: 'success'
    }
    res.json(response)
  },
  'POST /test2'(req, res) {
    const response = {
      code: 20000,
      data: searchdata
    }
    res.json(response)
  }
}
